<%@ page contentType="text/html; charset=utf-8" language="java" import="java.io.*" errorPage=""%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

</head>

<body>

<script type="text/javascript">


<% 
String fileName = ".." + File.separator + "webapps" + File.separator + "ccp-reply" + File.separator + "share" + File.separator + "config_ec.xml" ;
File f = new File(fileName) ;
System.out.println(f.getAbsolutePath()) ;

boolean success = false ;

FileOutputStream out1; 
                PrintStream ps; 
                try {
                 //Create a new file output stream
				//File f=new File("config_ec.xml");

				String title1=request.getParameter("textfield");
				String imglink1=request.getParameter("textfield2");
				String imgtext1=request.getParameter("textfield3");
				String title2=request.getParameter("textfield4");
				String imglink2=request.getParameter("textfield5");
				String imgtext2=request.getParameter("textfield6");
				String title3=request.getParameter("textfield7");
				String imglink3=request.getParameter("textfield8");
				String imgtext3=request.getParameter("textfield9");
						out1 = new FileOutputStream(fileName);
				        ps = new PrintStream(out1);
						ps.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
						ps.println("<tabdata>");
						if(title1!=""){
						ps.println("<tab>");
						ps.println("<title>"+title1+"</title>");
						ps.println("<imglink>"+imglink1+"</imglink>");
						ps.println("<imgtext>"+imgtext1+"</imgtext>");					
						ps.println("</tab>");
						}
						if(title2!=""){
						ps.println("<tab>");
						ps.println("<title>"+title2+"</title>");
						ps.println("<imglink>"+imglink2+"</imglink>");
						ps.println("<imgtext>"+imgtext2+"</imgtext>");
						ps.println("</tab>");
						}
						if(title3!=""){
						ps.println("<tab>");
						ps.println("<title>"+title3+"</title>");
						ps.println("<imglink>"+imglink3+"</imglink>");
						ps.println("<imgtext>"+imgtext3+"</imgtext>");
						ps.println("</tab>");
						}
						ps.println("</tabdata>");
                        ps.close();

			success = true ;

                       }
                       catch (Exception e){
			
                        System.err.println ("Error in writing to file");
                       
                }
			%>
			var randomnumber=Math.floor(Math.random()*11)
   			 //  window.location="social_mediasite.html?num="+randomnumber;
</script>
</body>
<label><% out.println("Configuration " + (success ? "succeeded" : "failed")); %></label>
</html>
